# koroFileHeader at Yungoal acer
# Create: 2023-10-20 16:03:03
# LastEdit: 2023-10-25 17:29:50
"""https://next.api.aliyun.com/api-tools/sdk/ResourceManager"""
__author__ = '749B'


from alibabacloud_resourcemanager20200331.client import Client as ResourceManager20200331Client
from alibabacloud_resourcemanager20200331 import models as resource_manager_20200331_models

def list_resource_groups(
    client: ResourceManager20200331Client,
    page_size: int = 50,
    include_tags: bool = True,
    ):
    """列出有权限的资源组
    https://next.api.aliyun.com/api/ResourceManager/2020-03-31/ListResourceGroups
    """
    request = resource_manager_20200331_models.ListResourceGroupsRequest(
        include_tags=include_tags,
        )
    total_count, page_number = None, None
    while total_count is None or page_size * page_number < total_count:
        response = client.list_resource_groups(request)
        body = response.body.to_map()
        total_count = body['TotalCount']
        page_size = body['PageSize']
        page_number = body['PageNumber']
        for resource_group in body['ResourceGroups']['ResourceGroup']:
            yield resource_group
        request.page_number = page_number + 1

def list_resources(
    client: ResourceManager20200331Client,
    page_size: int = 60,  # 取值范围：1~100。默认值：10。
    ):
    """列出当前账号可以访问的资源信息
    https://next.api.aliyun.com/api/ResourceManager/2020-03-31/ListResources
    """
    request = resource_manager_20200331_models.ListResourcesRequest(
        page_size=page_size,
        )
    total_count, page_number = None, None
    while total_count is None or page_size * page_number < total_count:
        response = client.list_resources(request)
        body = response.body.to_map()
        total_count = body['TotalCount']
        page_size = body['PageSize']
        page_number = body['PageNumber']
        for resource in body['Resources']['Resource']:
            yield resource
        request.page_number = page_number + 1
